import request from '/@/utils/request';
import { useUrlUtil } from '/@/utils/urlUtil';
import { BaseResponse } from '/@/interfaces/BaseModel';
import { PermissionApi } from '/@/enums/jdfsystem-api-enum';
import { BaseRequest } from '/@/interfaces/BaseModel';
import {
    PermissionInfoSearchParamModel,
    PermissionInfoListModel,
    PermissionInfoDetailModel,
    PermissionInfoAddParamModel,
    PermissionInfoEditParamModel,
    PermissionInfoDeleteParamModel,
} from '/@/interfaces/JdfsystemModel';

function usePermissionInfo() {
    return {
        list: function (payload: BaseRequest<PermissionInfoSearchParamModel>) {
            return request.post<BaseResponse<PermissionInfoListModel[]>>(PermissionApi.LIST, payload);
        },
        detail: function (payload: { [key: string]: string | number }) {
            const useUrl = useUrlUtil();
            return request.get<BaseResponse<PermissionInfoDetailModel>>(useUrl.joinParam(PermissionApi.DETAIL, payload));
        },
        add: function (payload: BaseRequest<PermissionInfoAddParamModel>) {
            return request.post<BaseResponse<boolean>>(PermissionApi.ADD, payload);
        },
        edit: function (payload: BaseRequest<PermissionInfoEditParamModel>) {
            return request.post<BaseResponse<boolean>>(PermissionApi.EDIT, payload);
        },
        del: function (payload: BaseRequest<PermissionInfoDeleteParamModel>) {
            return request.post<BaseResponse<boolean>>(PermissionApi.DEL, payload);
        },
    };
}

export default usePermissionInfo;